//
//  OneViewController.swift
//  通知--swfit
//
//  Created by wsj on 17/8/9.
//  Copyright © 2017年 wsj. All rights reserved.
//

import UIKit
import UserNotifications
import SwiftGifOrigin
class OneViewController: UIViewController {

    @IBOutlet weak var imageView: UIImageView!
    override func viewDidLoad() {
        super.viewDidLoad()
        imageView.loadGif(name: "cry");
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
   
   
    
    
}
extension OneViewController
{
    /// 添加一般的action
    @IBAction func categoryAction(_ sender: UIButton) {
        if #available(iOS 10.0, *) {
            /// 注意 只有在间隔时间大于60秒的时候，才可以使用循环推送
            let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 3.0, repeats: false);
            UNNotification.sendLocalNotification(trigger,identifier: "wj_sevenSeconds");
            
        } else {
            // Fallback on earlier versions
        };
    }
    /// 添加可以回复的action
    @IBAction func categoryTextAction(_ sender: UIButton) {
        if #available(iOS 10.0, *) {
            /// 注意 只有在间隔时间大于60秒的时候，才可以使用循环推送
            let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 3.0, repeats: false);
            UNNotification.sendLocalNotification(trigger,identifier: "wj_sevenSeconds_text");
            
        } else {
            // Fallback on earlier versions
        };
    }
    /// 自定义UI界面显示
    @IBAction func notificationCustomUI(_ sender: UIButton) {
        if #available(iOS 10.0, *) {
            let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 3.0, repeats: false)
            UNNotification.sendLocalNotification(trigger,identifier: "wj_sevenSeconds_customUI",isAttachment: true);
        } else {
            // Fallback on earlier versions
        };
        
    }
    /// 删除通知
    @IBAction func removeNotification(_ sender: UIButton) {
        
        if #available(iOS 10.0, *) {
            let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5.0, repeats: false)
            UNNotification.sendLocalNotification(trigger,identifier: "wj_sevenSeconds_remove",isRemove: true);
        } else {
            // Fallback on earlier versions
        }
       
    }
}
